﻿/*
 * Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
 * See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
 * for more information concerning the license and the contributors participating to this project.
 */

using System.Security.Claims;
using static AspNet.Security.OAuth.Weibo.WeiboAuthenticationConstants;

namespace AspNet.Security.OAuth.Weibo;

/// <summary>
/// Defines a set of options used by <see cref="WeiboAuthenticationHandler"/>.
/// </summary>
public class WeiboAuthenticationOptions : OAuthOptions
{
    public WeiboAuthenticationOptions()
    {
        ClaimsIssuer = WeiboAuthenticationDefaults.Issuer;
        CallbackPath = WeiboAuthenticationDefaults.CallbackPath;

        AuthorizationEndpoint = WeiboAuthenticationDefaults.AuthorizationEndpoint;
        TokenEndpoint = WeiboAuthenticationDefaults.TokenEndpoint;
        UserInformationEndpoint = WeiboAuthenticationDefaults.UserInformationEndpoint;

        ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id");
        ClaimActions.MapJsonKey(ClaimTypes.Name, "name");
        ClaimActions.MapJsonKey(ClaimTypes.Gender, "gender");
        ClaimActions.MapJsonKey(Claims.ScreenName, "screen_name");
        ClaimActions.MapJsonKey(Claims.ProfileImageUrl, "profile_image_url");
        ClaimActions.MapJsonKey(Claims.AvatarLarge, "avatar_large");
        ClaimActions.MapJsonKey(Claims.AvatarHd, "avatar_hd");
        ClaimActions.MapJsonKey(Claims.CoverImagePhone, "cover_image_phone");
        ClaimActions.MapJsonKey(Claims.Location, "location");
    }

    /// <summary>
    /// Gets or sets the address of the endpoint exposing
    /// the email addresses associated with the logged in user.
    /// </summary>
    public string UserEmailsEndpoint { get; set; } = WeiboAuthenticationDefaults.UserEmailsEndpoint;
}
